<?php

namespace App\Http\Controllers\Api;

use App\Models\Agreement;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
class AdminOrderController extends Controller
{

    protected function ReturnMessage($status=-1,$msg='',$list=[]){
        $data = [];
        $data['status'] = $status;
        $data['msg'] = $msg;
        $data['list'] =$list;
        return $data;
    }
    public function getGoodsPlan(Request $request){
        $type = $request->q;
        $array = DB::table('goods_plan')->whereType($type)->pluck('planname','planid');
        return $array;
    }
    public function getGoodsPlanid(Request $request){
        $type = $request->q;
        $array = DB::table('goods_plan')->wherePlanname($type)->value('planid');
        return array($array);
    }

    /**
     * 获取cookies
     *
     */
    public function get_cookies(Request $request){
        $store_id = $request->mid;
        if ( !$store_id ) {
            return json_encode(['code'=> 201, 'msg'=> '参数有误']);
        }
        $cookies_info = DB::table('taobao_cookies')->where(['status'=> 1, 'mid'=> $store_id])->orderBy('id', 'desc')->first();
        if ( !$cookies_info ) {
            return json_encode(['code'=> 201, 'msg'=> '未查询到cookies信息']);
        }

        return json_encode(['code'=> 200, 'msg'=> 'success', 'cookies'=> $cookies_info-> cookies]);
    }
}
